<div id="tab-system" class="HuiTab">
	<div class="tabBar cl">
		<span class="current">数据库表列表</span>
	</div>
	<br>
</div>
<div class="dataTables_wrapper no-footer">
<table class="table table-border table-bordered table-bg table-striped table-hover">
	<thead>
		<tr class="text-c">
			<th width="25">编号</th>
			<th>表名</th>
			<th>是否有主键</th>
			<th>是否有附加属性</th>
			<th width="110">操作</th>
		</tr>
	</thead>
	<tbody>
	<% 
		var i = 0;
		for(obj in list){ 
			i++;
	%>
		<tr class="text-c">
			<td>${i}</td>
			<td>${obj.tablename}</td>
			<td>${obj.hasid}</td>
			<td>${obj.hasext}</td>
			<td class="td-manage" width="160">
				<a class="btn btn-secondary size-MINI" href="javascript:;" title="生成代码" onclick="list_gencode('${obj.id}','${obj.tablename}',${obj.hasid},${obj.hasext})"><i class="Hui-iconfont">&#xe6df;</i> 生成代码</a> 
			</td>
		</tr>
	<% } %>
	</tbody>
</table>
</div>

<div id="div_gencode" style="display: none;">
<div class="container-fluid" >
<form action="${BASE}/coder/fromdbSave" id="form_save" class="form form-horizontal" method="post">
  <div class="row cl">
    <label class="form-label col-sm-3">数据库表名：</label>
    <div class="formControls col-sm-8">
      <input type="text" class="input-text" name="tablename" id="tablename" readonly="readonly">
    </div>
    <div class="col-sm-1"> </div>
  </div>
  <div class="row cl">
    <label class="form-label col-sm-3">模块名称：</label>
    <div class="formControls col-sm-8">
      <input type="text" class="input-text" name="modulename" id="modulename">
    </div>
    <div class="col-sm-1"> </div>
  </div>
  <div class="row cl">
    <label class="form-label col-sm-3">实体类名：</label>
    <div class="formControls col-sm-8">
      <input type="text" class="input-text" name="entityclassname" id="entityclassname">
    </div>
    <div class="col-sm-1"> </div>
  </div>
  <div class="row cl">
    <label class="form-label col-sm-3"> </label>
    <div class="formControls col-sm-8">
      <button type="submit" class="btn btn-secondary" title="生成代码">生成代码</button>
    </div>
    <div class="col-sm-1"> </div>
  </div>
  
</form>
</div>
</div>

<script type="text/javascript">
var form_layer;
function list_gencode(id,name,hasid,hasext){
	$("#tablename").val(name);
	form_layer = layer.open({
	  type: 1,
	  title :'代码生成规则',
	  area: ['500px', '300px'],
	  content: $('#div_gencode')
  });
}

$(function(){
	$("#form_save").Validform({
		tiptype:2,
		ajaxPost:true,
		postonce:true,
		callback:function(data){
			$.Hidemsg();
			if("200"==data.retCode){
				layer.close(form_layer);
				layer.msg('保存成功！', {icon: 6,offset: '45px'});
			}else{
				layer.msg('保存失败！', {icon: 5,offset: '45px'});
			}
		}
	});
});
</script>
